import React,{lazy,Suspense} from "react";
import {useRoutes} from "react-router-dom";
import Loading from "@/components/Loading";
const Index = lazy(()=>import("@/pages/Index"));// 主页
const Login = lazy(()=>import("@/pages/Login"));// 登陆页
const NotFound = lazy(()=>import("@/pages/NotFound"));// 404
export default function(){
    const renderRouter = useRoutes([
        {
            path:"/",
            element:(
                // fallback:当正在加载所包裹的元素时，所呈现的内容
                <Suspense fallback={<Loading/>}>
                    <Index></Index>
                </Suspense>
            )
        },{
            path:"/login",
            element:(
                <Suspense fallback={<Loading/>}>
                    <Login></Login>
                </Suspense>
            )
        },{
            path:"*",
            element:(
                <Suspense fallback={<Loading/>}>
                    <NotFound></NotFound>
                </Suspense>
            )
        }
    ])
    return renderRouter;
}